1. Field of the Invention
This invention generally relates to an arithmetic processor and more particularly to an improved floating point processor which can perform arithmetic operation on the fraction of a floating point number, obtain the absolute value of the result of the operation and round the result of the operation at high speed by using a small number of circuit elements.
2. Description of The Related Art
Ordinary floating point operation is performed by a processor having typical construction as shown in FIG. 1. In this figure, reference characters XI, Ex and Fx indicate input data, an exponent part (hereunder sometimes referred to simply as an exponent) and a fraction part (hereunder sometimes referred to simply as a fraction) of the input data, respectively. Further, reference characters YI, Ey and Fy denote another input data, an exponent part and a fraction part of the input data YI, respectively. Moreover, reference characters ZO, Ez and Fz indicate output data, an exponent part and a fraction part of the output data, respectively. Furthermore, reference numerals 500 and 501 indicate a processor for arithmetic operation of a fraction and an exponent comparator, respectively. Reference numerals 502, 503 and 504 indicate selection circuits. Furthermore, 505, 507, 509 and 510 indicate a shifter, an adder, a rounding circuit and a normalization circuit, respectively. Additionally, reference numerals 506 and 508 indicate complement data generators.
The operation of a conventional processor illustrated in FIG. 1 is now described in detail. First, the exponent parts Ex and Ey of the input data XI and YI are compared by the exponent comparator 501 by subtracting one of these exponent parts from the other thereof. Further, the selection circuits 502 and 503 are controlled such that the fraction part of the input data, of which the exponent part is less than that of the other data, of the parts Ex and Ey is inputted into the shifter 505 and on the other hand that of the other of the input data XI and YI is inputted into the complement data generator 506. Moreover, the selection circuit 504 is controlled such that the larger one of the exponent parts Ex and Ey is inputted into the normalization circuit 510. The absolute value of the difference between the exponent parts Ex and Ey is then inputted into the shifter 505. Next, the fraction inputted into the shifter 505 is shifted to right by the number of digits corresponding to the difference between the exponent parts Ex and Ey and the weight of corresponding bits of two fraction parts Fx and Fy are made equal to each other. At this time, additional three bits are obtained from the bits "crowded out of" the shifter 505 from the right end thereof by the shift of digits to right therein. The most significant bit of these three bits is called "a guard bit" and is the most significant one of the "crowded out" bits. The second most significant bit of the additional three bits is called "a round bit" and is the second most significant one of the "crowded out" bits. The least significant bit of the three bits, called "a sticky bit," is obtained by the logical OR of the remaining ones of the "crowded out" bits. These three bits are added to the least significant bit of the fraction part supplied to and shifted in the shifter 505 below the least significant bit thereof and are used to round the numerical value of the result of the arithmetic operation. Thereafter, if the arithmetic as to the fraction is addition, the fraction outputted from the selection circuit 502 is further outputted by the complement data generator 506 to the adder 507 as it is. On the other hand, if the arithmetic operation relating to the fraction is subtraction, the two's complement of the fraction outputted is generated and then outputted by the complement data generator 506 to the adder 507. Further, the fractions, of which the weight of corresponding bits are made equal to each other, are added by the adder 507. Then, in order to obtain the absolute value of the result of the addition of the fractions, in case that the result of the addition effected by the adder 507 is positive, the result of the addition is outputted by the complement data generator 508 to further output the rounding circuit 509 as it is. On the other hand, if the result of the addition is negative, the two's complement of the result of the addition effected by the adder 507 is generated and further outputted to the rounding circuit 509 by the complement data generator 508. In the rounding circuit 509, the value of the result of the arithmetic operation of the fraction received from the generator 508 is rounded. Finally, the value resulted from the above described arithmetic operations of the fractions (hereunder referred to simply as "the interim or temporary result") is shifted to right or left by the number of digits required to the normalization thereof by the normalization circuit 510. Thereafter, in case that the "interim result" is shifted to right, the amount of the shifted number of digits is added to the exponent inputted to the normalization circuit 510. Further, in case that the "interim result" is shifted to left, the amount of the shifted number of digits is subtracted from the exponent inputted to the normalization circuit 510. Moreover, fleating point overflow or fleating point underflow is detected by judging whether or not the result of this operation of the exponent exceeds a predetermined range. If not detected, the result of this operation is outputted as it is. Contrarily, if detected, the result of this operation is modified and thus the process of the above described operations is completed.
As above stated, in order to obtain the absolute value of the fraction, the output of the adder 507 is inputted to the rounding circuit 509 as it is if the output of the adder 507 is positive. Further, if negative, two's complement of the output of the adder 507 is to be generated and further outputted to the rounding circuit 509. Practically, the generation of the two's complement by this complement data generator 508 is effected by logically inverting each bit of the input data and further adding 1 to the least significant bit of the inverted input data. Accordingly, the conventional arithmetic circuit has a drawback that if the result of the arithmetic operation such as the addition of the fractions is negative, two's complement is to be generated and thus it takes much of the operation time and further the configuration of the circuits is complex.
Furthermore, in the arithmetic circuit, on completion of the addition of the fractions, the rounding of the result of the addition is effected by the rounding circuit 509. In this rounding operation, the digit to be rounded should be detected in the result, of which the absolute value is obtained, of the arithmetic operation and further a carry generated by the rounding should be added to the detected to digit. Thus, the prior art arithmetic circuit has a defect that in such a case, the rounding operation cannot be started unless the absolute value of the result of the arithmetic operation is determined and that it takes much of the operation time to round the result of the arithmetic circuit and the complex circuit is required for the rounding operation.
Further, the exponent comparator 501 is a circuit for comparing the two input data with each other, detecting the relation in magnitude between the two input data and obtaining the absolute value of the difference in magnitude between the two input data. Concurrently, the exponent comparator 501 subtracts a second input data from a first input data and judges from the overflow whether the result of the subtraction is positive or negative. Further, the exponent comparator 501 outputs the result of the subtraction as it is if the result of the subtraction is positive. If negative, the comparator 501 outputs two's complement of the result of the subtraction is outputted to obtain the value of the result when the sign of the value is reversed. The generation of the two's complement is concretely effected by logically reversing each bit of the input data and adding 1 to the least significant bit of the logically reversing data. Thus, if the result of the subtraction is negative, an operation of further adding 1 to the result thereof is additionally required. Therefore, the conventional arithmetic circuit has another drawback that it takes much time to obtain the absolute value of the difference and further the adder as well as the subtracter is needed so that the arithmetic processor becomes large in size.
Further, in the normalization circuit 510, a floating point underflow and a floating point overflow are detected. According to IEEE 754 Floating Point Arithmetic Standard, the number of digits of exponent part is determined to be 8 in case of single precision; 11 in case of double precision; and 15 in case of extended double precision, respectively. Further, the range of the exponent of the ordinary normalized floating point data Exp is as follows: EQU 0&lt;Exp&lt;2.sup.n -1 (where n is the number of digits in an exponent).
If the arithmetic operation of the exponent results in that Exp.ltoreq.0, a floating point underflow occurs. Further, if Exp.ltoreq.2.sup.n -1, a floating point overflow occurs. Namely, it is necessary to determine the range of the result of the operation of the exponent. Thus, the conventional arithmetic processor has still another drawback that if a floating point underflow or floating point overflow is detected after the exponent correction operation accompanied by the normalization of the fraction is fully completed, the output of the detection signal is delayed.